<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div class="nav">
        <a href="#/home">首页</a>
        <a href="#/server">服务</a>
        <a href="#/mine">个人中心</a>
    </div>
    <div class="content"></div>
    
</body>

<script>
    //用hashchange事件监听url地址中hash的值变化，hashchange的回调函数就会执行
    //用loocationa.hash获取最新的hash值，用switch根据不同的Hash值调用不同的函数
    window.onhashchange=function(){
        switch(location.hash){
            case '#/home': home_page();break
            case '#/server': server_page();break
            case '#/mine': mine_page();break
        }
    }
    //渲染
    function home_page(){
        document.querySelector('.content').innerHTML='首页内容'
    }
    function server_page(){
        document.querySelector('.content').innerHTML='服务内容'
    }
    function mine_page(){
        document.querySelector('.content').innerHTML='个人中心内容'
    }

</script>
</html>